package com.obas.view {
    import com.obas.event.ItestOperationEvent;

    import flash.events.EventDispatcher;

    import mx.events.ListEvent;

    [Event(name="{com.obas.event.ItestOperationEvent.REQUEST_ID}", type="com.obas.event.ItestOperationEvent")]
    public class ExplorerViewMediator extends EventDispatcher {
        public var _view:ExplorerView;

        [InjectableView]
        /**
         * The mediator's view.
         */
        public function get view():ExplorerView {
            return _view;
        }

        public function set view(value:ExplorerView):void {
            _view = value;
            init();
        }

        private function init():void {
            dispatchEvent(new ItestOperationEvent([_view.viewId]));
        }

        private function onDbClick(event:ListEvent):void {
            var item:Object = event.itemRenderer.data;
        }

//        [ResponseHandler("{com.obas.event.ItestOperationEvent.RETURN_ID}")]
//        public function onRequestExplorerEvent(event:CommandCompletionEvent):void {
//            if (event.error) {
//                ErrorManager.showErrorMessage(ResourceUtil.getErrorString("", event.error));
//                return;
//            }
//            var exps:ArrayCollection = event.result as ArrayCollection;
//            if (null != exps && exps.length > 0) {
//               if (exps.length == 1) {
//                  view.label = (exps.getItemAt(0) as Explorer).name;
//                  openExplorer(exps.getItemAt(0) as Explorer);
//               }
//               else {
//                  _view.tabNavigator.showTabBar = true;
//                  exps.sort = new Sort();
//                  var sortField:SortField = new SortField();
//                  sortField.name = "ordinal";
//                  sortField.numeric = true;
//                  exps.sort.fields = [sortField];
//                  exps.refresh();
//                  for each (var exp:Explorer in exps) {
//                     openExplorer(exp);
//                  }
//               }
//               _view.tabNavigator.deferredSelectedIndex = 0;
//            }
//        }
//
//        private function openExplorer(exp:Explorer):void {
//            _view.tabDatas.addItem(exp);
//            var naviView:NavigationView = new NavigationView();
//            naviView.label = exp.name;
//            naviView.explorerData = exp;
//            naviView.menuType = view.menuType;
//            _view.tabNavigator.addDeferredChild(naviView);
//            _view.tabNavigator.deferredSelectedIndex = 0;
//        }
    }
}